<?php

namespace AppBundle\DataFixtures\ORM;

use AppBundle\Entity\Country;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

/**
 * @see Country
 * @author Vlad Riabchenko <vriabchenko@webnet.fr>
 */
class LoadCountries extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * @inheritdoc
     */
    public function load(ObjectManager $manager)
    {
        $france = (new Country())
            ->setName('France');
        $this->addReference('country_france', $france);
        $manager->persist($france);

        $germany = (new Country())
            ->setName('Germany');
        $this->addReference('country_germany', $germany);
        $manager->persist($germany);

        $manager->flush();
    }

    /**
     * @inheritdoc
     */
    public function getOrder()
    {
        return 1;
    }
}
